<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>JavaScript操作DOM节点</title>
<script type="text/javascript">
	function modifyDOM(){
		document.getElementById("txt").innerHTML="用户名：";
		document.getElementById("userName").value="Jack";
	}
	
	function addDOM(){
		var para=document.createElement("p");
		var node=document.createTextNode("...前...");
		var para2=document.createElement("p");
		var node2=document.createTextNode("...后...");
		para.appendChild(node);
		para2.appendChild(node2);
		var parent=document.getElementById("parent");
		var son1=document.getElementById("son1");
		parent.insertBefore(para, son1);
		parent.appendChild(para2);
	}
	
	function removeDOM(){
		var parent=document.getElementById("parent");
		var son1=document.getElementById("son1");
		parent.removeChild(son1);
	}
</script>
</head>
<body>
<div id="parent">
	<div id="son1">
		<font id="txt">:</font><input type="text" id="userName" name="userName"/>
	</div>
</div>
<input type="button" value="修改DOM节点" onclick="modifyDOM()"/>
<input type="button" value="添加DOM节点" onclick="addDOM()"/>
<input type="button" value="删除DOM节点" onclick="removeDOM()"/>
</body>
</html>